package com.neusoft.my12306.service.impl;

import com.baomidou.mybatisplus.core.assist.ISqlRunner;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neusoft.my12306.common.res.CommonResult;
import com.neusoft.my12306.entity.Schedule;
import com.neusoft.my12306.entity.Station;
import com.neusoft.my12306.mapper.ScheduleMapper;
import com.neusoft.my12306.mapper.StationMapper;
import com.neusoft.my12306.service.IScheduleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 葛彬
 * @since 2023-07-19
 */
@Service
public class ScheduleServiceImpl  extends ServiceImpl<ScheduleMapper, Schedule> implements IScheduleService {

    @Autowired
    ScheduleMapper scheduleMapper;

    @Override
    public CommonResult queryTrain(String fromCity,String towardCity) {

//        List<CommonResult> commonResultList=scheduleMapper.queryTrain(fromCity,towardCity);
        return new CommonResult(200,"success",scheduleMapper.queryTrain(fromCity,towardCity));
    }

    @Override
    public CommonResult calPrice(Schedule schedule) {

        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("trainno", schedule.getTrainno());
        List<Schedule> lss = baseMapper.selectList(queryWrapper);
        CommonResult result = new CommonResult(lss);
        if (lss == null || lss.size() == 0)
            result.setNotFound();
        return result;
    }
}
